import { createRouter, createWebHistory, RouteRecordRaw, RouterView } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/map',
    name: 'BaiduMap',
    component: () => import('@/page/map/BaiduMap.vue'),
    meta: { title: '登录' }
  },
  {
    path: '/',
    name: 'HomeIndex',
    component: () => import('@/page/layout/BasicLayout.vue'),
    redirect: '/map',
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/HomeView.vue'),
        meta: { title: '首页', hidden: true }
      },
      {
        path: '/system',
        name: 'System',
        component: RouterView,
        meta: { title: '系统管理', icon: 'setting' },
        children: [
          {
            path: '/system/dict',
            name: 'SystemDictList',
            component: () => import('@/page/system/dict/DictList.vue'),
            meta: { title: '字典管理', icon: 'table', permission: 'system_dict' }
          },
          {
            path: '/system/school',
            name: 'SystemSchoolList',
            component: () => import('@/page/system/school/SchoolList.vue'),
            meta: { title: '学校管理', icon: 'share-alt', hidden: true, permission: 'system_school' }
          },
          {
            path: '/system/user',
            name: 'SystemUserList',
            component: () => import('@/page/system/user/UserList.vue'),
            meta: { title: '用户管理', icon: 'user', permission: 'system_user' }
          },
          {
            path: '/system/role',
            name: 'SystemRoleList',
            component: () => import('@/page/system/role/RoleList.vue'),
            meta: { title: '角色管理', icon: 'usergroup-add', permission: 'system_role' }
          },
          {
            path: '/system/org',
            name: 'SystemOrgList',
            component: () => import('@/page/system/org/OrgList.vue'),
            meta: { title: '组织机构', icon: 'share-alt', permission: 'system_org' }
          },
          {
            path: '/system/log',
            name: 'SystemLogList',
            component: () => import('@/page/system/log/LogList.vue'),
            meta: { title: '日志管理', icon: 'share-alt', permission: 'system_log' }
          }
        ]
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
